define(['jquery', 'bootstrap', 'agent', 'table', 'form'], function ($, undefined, Agent, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'goods/index',
                    multi_url: 'shop_goods/multi',
                    table: 'goods',
                }
            });
            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                showExport: false,
                showColumns: false,
                showToggle: false,
                commonSearch:false,
                columns: [
                    [
                        {field: 'id', title: '产品ID', operate: false},
                        {field: 'cover_img', title: '封面图', events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
                        {field: 'goods_name', title: '产品名称', operate: 'LIKE'},
                        {field: 'createtime', title: '创建时间', formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true,operate: false},
                        {field: 'updatetime', title: '更新时间', formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true,operate: false},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});